from django.http import HttpResponse, HttpResponseRedirect
from examples.test.models import SchemaTest

def test_session(request):
    inc = request.session.get("inc", 0)
    inc = inc + 1
    request.session['inc'] = inc
    return HttpResponse("inc: %s" % inc, mimetype="text/plain")	
    
    
def test_schema(request):
    inc = request.session.get("inc", 0)
    inc = inc + 1
    request.session['inc'] = inc
    test = SchemaTest(
        title="Essai titre %s" % inc
    )
    test.save()
    return HttpResponseRedirect("/%s" % test.id)
    
def display_test(request, id):
    print "id = %s" % id
    if id is not None:
        test = SchemaTest.load(id)
        
    return HttpResponse("titre %s" % test.title)